package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.ProductUnitMapper;
import com.atguigu.spzx.manager.service.ProductUnitService;
import com.atguigu.spzx.model.entity.product.ProductUnit;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * title:
 * author: zgl
 * date: 2024/1/4
 * description：
 */
@Service
public class ProductUnitServiceImpl implements ProductUnitService {
    @Autowired
    private ProductUnitMapper productUnitMapper;

    @Override
    public List<ProductUnit> allProductUnit() {
        return productUnitMapper.getUnitList();
    }

    @Override
    public PageInfo<ProductUnit> getUnitList(Integer pageNum, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        //查询数据库
        List<ProductUnit> unitList = productUnitMapper.getUnitList();
        return new PageInfo<>(unitList);
    }

    @Override
    public ProductUnit getUnitById(Long id) {
        return productUnitMapper.getUnitById(id);
    }

    @Override
    public void deletedUnit(Long id) {
        productUnitMapper.deletedUnit(id);
    }

    @Override
    public void updateUnit(ProductUnit unit) {
        productUnitMapper.updateUnit(unit);
    }

    @Override
    public void saveUnit(ProductUnit unit) {
        productUnitMapper.saveUnit(unit);
    }
}
